package xj.graph2d.command;

import xj.graph2d.DrawShape;
import xj.graph2d.SimpleDrawDocument;
import xj.graph2d.SimpleDrawView;

public class RotationCommand extends DeltaCommand {

  public RotationCommand(SimpleDrawView view, 
			 SimpleDrawDocument doc,
			 DrawShape shape) {
    super(view, doc, shape);
    startAngle = endAngle = shape.getRotationAngle();
  }

  @Override
  public void move(float dx, float dy) {
    super.move(dx, dy);
    endAngle = shape.getRotationAngle();
  }

  @Override
  protected void forward() {
    shape.setRotationAngle(endAngle);
  }

  @Override
  protected void backward() {
    shape.setRotationAngle(startAngle);
  }

  @Override
  public boolean isSignificant() {
    return (startAngle != endAngle);
  }

  protected float startAngle;

  protected float endAngle;

}
